#include<bits/stdc++.h>

using namespace std;

#define lowbit(x) (x & (-x) )

typedef long long ll;

const int N = 100010;

ll tr[N][2];
int n,m;

void add(int x, ll c, int f)
{
	for(int i = x; i <= n; i += lowbit(i) )
	{
		tr[i][f] += c;
	}
}

ll sum(int x, int f)
{
	ll res = 0;
	for(int i = x; i; i -= lowbit(i) )
	{
		res += tr[i][f];
	}
	return res;
}

ll get(int x)
{
	ll ans = (x + 1) * sum(x, 0) - sum(x, 1);
}

int main()
{
	cin>>n>>m;
	ll a = 0,b;
	for(int i = 1; i <= n; i ++ )
	{
		cin>>b;
		add(i, b - a, 0);
		add(i, (b - a) * i, 1);
		a = b;
	}
	for(int i = 1; i <= m; i ++ )
	{
		char f;
		cin>>f;
		int x,l,r;
		ll d;
		if(f == 'Q')
		{
			cin>>l>>r;
			cout<<get(r) - get(l - 1)<<endl;
		}
		else
		{
			cin>>l>>r>>d;
			add(l, d, 0);
			add(r + 1, -d, 0);
			add(l, d * l, 1);
			add(r + 1, -d * (r + 1), 1);
		}
	}
	return 0;
}

